home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: What is &Variable (declared as: char Variable[10])?
- Date: 27 Feb 1996 15:47:07 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb27084707@qcd.lanl.gov>
- References: <4gqpa1$3h9@alcor.usc.edu> <1996Feb26.211807.28858@isac.hces.com>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: gg@isac.hces.com's message of Mon, 26 Feb 1996 21:18:07 GMT
-
- In article <1996Feb26.211807.28858@isac.hces.com>
- gg@isac.hces.com (Greg Goodrich) writes:
-
- GG: This is because C treats the occurrence of array names as the address of
- GG: the array. Therefore the following are equivalent:
- GG:
- GG: scanf("%s", myarray);
- GG: scanf("%s", &myarray);
- GG:
-
- I am amazed at the number of wrong answers this simple question
- got. myarray and &myarray are equivalent in exactly the same sense
- that 1 and 1.0 are equivalent. myarray is a pointer to char (it is the
- same as &myarray[0]), whereas myarray ia a pointer to an array of 10
- chars. Only the first ought to be passed to scanf when the format
- specified is %s.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-